

package jumavidesktop.Persistencia.entidades;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author vimso
 */
@Entity
@Table(name = "matricula")
@NamedQueries({
    @NamedQuery(name = "Matricula.findAll", query = "SELECT m FROM Matricula m"),
    @NamedQuery(name = Matricula.BUSCAR_POR_MATRICULA, query = "SELECT m FROM Matricula m WHERE m.matricula =:"+Matricula.PA_BUSCAR_MATRICULA),
    })

public class Matricula implements Serializable {
    
    
    //<editor-fold defaultstate="collapsed" desc="Constatnes nameqquery">
    public static final String BUSCAR_POR_MATRICULA = "Matricula.findByMatricula";
    

    public static final String PA_BUSCAR_MATRICULA = "matricula";
    //</editor-fold>
    
    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @Column(name = "Matricula")
    @Id
    private String matricula;
    @Column(name = "FechaAlta")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fechaAlta;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "matricula")
    private List<Movimientos> movimientosList;
    @JoinColumn(name = "Usuario", referencedColumnName = "Id",insertable = true, updatable = true,nullable=false)
    @ManyToOne(optional = false)
    private Usuario usuario;

    public Matricula() {
    }

    public Date getFechaAlta() {
        return fechaAlta;
    }

    public void setFechaAlta(Date fechaAlta) {
        this.fechaAlta = fechaAlta;
    }

    public List<Movimientos> getMovimientosList() {
        return movimientosList;
    }

    public void setMovimientosList(List<Movimientos> movimientosList) {
        this.movimientosList = movimientosList;
    }

    public Usuario getUsuario() {
        return usuario;
    }

    public void setUsuario(Usuario usuario) {
        this.usuario = usuario;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (matricula != null ? matricula.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Matricula)) {
            return false;
        }
        Matricula other = (Matricula) object;
        if ((this.matricula == null && other.matricula != null) || (this.matricula != null && !this.matricula.equals(other.matricula))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "jumavidesktop.Persistencia.entidades.Matricula[ matricula=" + matricula + " ]";
    }

    public String getMatricula() {
        return matricula;
    }

    public void setMatricula(String matricula) {
        this.matricula = matricula;
    }

}
